function select_all(ele){
	if(ele.checked) $("form :checkbox").attr("checked", "true");
	else $("form :checkbox").removeAttr("checked");
}
function delete_selected(form){
	if(confirm('Are you sure to delete?')){
		$('input[name=form]').val("delete_items");
		$('form[name='+form+']').submit();
	}
}
function set_confirmed(form, state){
	$('input[name=set_confirmed]').val(state);
	$('input[name=form]').val("set_items_confirmed");

	$('form[name='+form+']').submit();
}
function set_published(form, state){
	$('input[name=set_published]').val(state);
	$('input[name=form]').val("set_items_published");

	$('form[name='+form+']').submit();
}
Array.prototype.inArray = function(value) {
	for (var i = 0, loopCnt = this.length; i < loopCnt; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};
if (!Array.indexOf) {
	Array.prototype.indexOf = function (obj) {
		var index;
		for (var i = 0; i < this.length; i++) {
			if (this[i] == obj) {
	 			index = i;
	 			break;
			}
		}
		if(index) return index;
		else return -1;
	}
}
function change (el, max_len, id) {
	if (el.value.length > max_len) {
		el.value = el.value.substr(0, max_len);
	}
	document.getElementById(id).innerHTML = max_len - el.value.length;
	return true;
}
function alternate(id, odd_row_class_name, even_row_class_name){
	var table = document.getElementById(id);  
	var rows = table.getElementsByTagName("tr");  
	for(i = 0; i < rows.length; i++){          
		if(i % 2 == 0){
			rows[i].className = even_row_class_name;
		}else{
			rows[i].className = odd_row_class_name;
		}      
	}
}
function print_toolbar(toolbar_string){
	$('#ToolBar').html(toolbar_string);
}